package edu.scau.misp.shop.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * 商品实体类
 * @author DCJ
 * 
 */
@Entity
@Table(name = "goods")
public class Goods implements java.io.Serializable {
	private static final long serialVersionUID = 1L;
	private Integer id;
	private GoodsType goodsType;
	private String name;  //名称
	private String spec;  //型号规格
	private String unit;   //单位
	private Double price; //价格
	private String introduce; //描述
	private String isSold; //是否上架

	public Goods() {
	}

	public Goods(Integer id, GoodsType goodsType, String name, String spec,
				String unit, Double price, String introduce, String isSold) {
			this.id = id;
			this.goodsType = goodsType;
			this.name = name;
			this.spec = spec;
			this.unit = unit;
			this.price = price;
			this.introduce = introduce;
			this.isSold = isSold;
		}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}	

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "TYPE_ID", nullable = false)
	public GoodsType getGoodsType() {
		return this.goodsType;
	}

	public void setGoodsType(GoodsType goodsType) {
		this.goodsType = goodsType;
	}

	@Column(name = "NAME", nullable = false)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	
	@Column(name = "SPEC", nullable = false )
	public String getSpec() {
		return spec;
	}

	public void setSpec(String spec) {
		this.spec = spec;
	}

	@Column(name = "UNIT", nullable = false )
	public String getUnit() {
		return unit;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	@Column(name = "PRICE", nullable = false, precision = 22, scale = 0)
	public Double getPrice() {
		return this.price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	@Column(name = "INTRODUCE")
	public String getIntroduce() {
		return this.introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	@Column(name = "IS_SOLD", nullable = false)
	public String getIsSold() {
		return this.isSold;
	}

	public void setIsSold(String isSold) {
		this.isSold = isSold;
	}
}